const obj1 = {
    name: "echo",
    foo: function (num1, num2) {
        console.log(this);
        console.log(this.name, num1 + num2);
    }
}
const obj2 = {
    name: "wer"
}
Function.prototype.HYApply = function (thisArg, args) {
    const fn = this;
    thisArg = (thisArg !== null && thisArg !== undefined) ? Object(thisArg) : window;
    thisArg.fn = fn;
    //这里的空值合并运算符可能会跟beautify插件产生冲突
    let arg = args ?? [];
    const result = thisArg.fn(...arg);
    return result;
};
obj1.foo.apply(obj2);
obj1.foo.HYApply(obj2);